package com.ecut.xzh.config;


import com.ecut.xzh.properties.RedissonProperties;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

/**
 * @author XZH
 */
@Configuration
public class RedissonConfig {

    @Resource
    private RedissonProperties redissonProperties;

    @Bean
    public RedissonClient redissonClient() {

        // 配置Redis服务器地址
        Config config = new Config();
        config.useSingleServer().setAddress("redis://" + redissonProperties.getHost() + ":" + redissonProperties.getPort())
                .setPassword(redissonProperties.getPassword());
        // 创建redissonClient对象
        return Redisson.create(config);

    }
}
